home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
FromTheMag
/
JW FLV MEDIA PLAYER 4.2
/
mediaplayer.exe
/
player.swf
/
scripts
/
com
/
jeroenwijering
/
utils
/
Animations.as
next >
Wrap
Text File
|
2008-11-04
|
3KB
|
111 lines
package com.jeroenwijering.utils
{
import flash.display.MovieClip;
import flash.events.Event;
public class Animations
{
public function Animations()
{
super();
}
public static function fade(param1:MovieClip, param2:Number = 1, param3:Number = 0.2) : void
{
if(param1.alpha > param2)
{
param1.spd = -Math.abs(param3);
}
else
{
param1.spd = Math.abs(param3);
}
param1.end = param2;
param1.addEventListener(Event.ENTER_FRAME,fadeHandler);
}
private static function fadeHandler(param1:Event) : void
{
var _loc2_:* = undefined;
_loc2_ = MovieClip(param1.target);
if(_loc2_.alpha >= _loc2_.end - _loc2_.spd && _loc2_.spd > 0 || _loc2_.alpha <= _loc2_.end + _loc2_.spd && _loc2_.spd < 0)
{
_loc2_.removeEventListener(Event.ENTER_FRAME,fadeHandler);
_loc2_.alpha = _loc2_.end;
if(_loc2_.end == 0)
{
_loc2_.visible = false;
}
}
else
{
_loc2_.visible = true;
_loc2_.alpha += _loc2_.spd;
}
}
private static function writeHandler(param1:Event) : void
{
var _loc2_:MovieClip = null;
var _loc3_:Number = NaN;
_loc2_ = MovieClip(param1.target);
_loc3_ = Math.floor((_loc2_.str.length - _loc2_.tf.text.length) / _loc2_.spd);
_loc2_.tf.text = _loc2_.str.substr(0,_loc2_.str.length - _loc3_);
if(_loc2_.tf.text == _loc2_.str)
{
_loc2_.tf.htmlText = _loc2_.str;
_loc2_.removeEventListener(Event.ENTER_FRAME,easeHandler);
}
}
private static function easeHandler(param1:Event) : void
{
var _loc2_:MovieClip = null;
_loc2_ = MovieClip(param1.target);
if(Math.abs(_loc2_.x - _loc2_.xps) < 1 && Math.abs(_loc2_.y - _loc2_.yps) < 1)
{
_loc2_.removeEventListener(Event.ENTER_FRAME,easeHandler);
_loc2_.x = _loc2_.xps;
_loc2_.y = _loc2_.yps;
}
else
{
_loc2_.x = _loc2_.xps - (_loc2_.xps - _loc2_.x) / _loc2_.spd;
_loc2_.y = _loc2_.yps - (_loc2_.yps - _loc2_.y) / _loc2_.spd;
}
}
public static function ease(param1:MovieClip, param2:Number, param3:Number, param4:Number = 2) : void
{
if(!param2)
{
param1.xps = param1.x;
}
else
{
param1.xps = param2;
}
if(!param3)
{
param1.yps = param1.y;
}
else
{
param1.yps = param3;
}
param1.spd = param4;
param1.addEventListener(Event.ENTER_FRAME,easeHandler);
}
public static function write(param1:MovieClip, param2:String, param3:Number = 1.5) : void
{
param1.str = param2;
param1.spd = param3;
param1.tf.text = "";
param1.addEventListener(Event.ENTER_FRAME,writeHandler);
}
}
}